<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta charset="utf-8" />
    <title>新增公众号 第三步{:config('APP_NAME')}</title>

    <meta name="description" content="overview &amp; stats" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

    <!-- bootstrap & fontawesome -->
    <link rel="stylesheet" href="__PUBLIC__/static/css/bootstrap.min.css" />
    <link rel="stylesheet" href="__PUBLIC__/static/css/font-awesome.min.css" />

    <!-- page specific plugin styles -->

    <!-- text fonts -->


    <!-- ace styles -->
    <link rel="stylesheet" href="__PUBLIC__/static/css/ace.min.css" />

    <!--[if lte IE 9]>
    <link rel="stylesheet" href="__PUBLIC__/static/css/ace-part2.min.css" />
    <![endif]-->
    <link rel="stylesheet" href="__PUBLIC__/static/css/ace-skins.min.css" />
    <link rel="stylesheet" href="__PUBLIC__/static/css/ace-rtl.min.css" />

    <!--[if lte IE 9]>
    <link rel="stylesheet" href="__PUBLIC__/static/css/ace-ie.min.css" />
    <![endif]-->
    <link rel="stylesheet" href="__PUBLIC__/static/js/webuploader-0.1.5/webuploader.css">
    <!-- inline styles related to this page -->
    <style>
        #ctlBtn{vertical-align: top;}
        .webuploader-container{display: inline-block;}
        .webuploader-pick{padding:11px 15px;}
    </style>
    <!-- ace settings handler -->
    <script src="__PUBLIC__/static/js/ace-extra.min.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

    <!--[if lte IE 8]>
    <script src="__PUBLIC__/static/js/html5shiv.js"></script>
    <script src="__PUBLIC__/static/js/respond.min.js"></script>
    <![endif]-->
</head>

<body class="no-skin">
{include file="common/header"}
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try{ace.settings.check('main-container' , 'fixed')}catch(e){}
    </script>

    {include file="common/left"}
    <div class="main-content">
        <div class="breadcrumbs  breadcrumbs-fixed" id="breadcrumbs">
            <script type="text/javascript">
                try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
            </script>

            <ul class="breadcrumb">
                <li>
                    <i class="ace-icon fa fa-home home-icon"></i>
                    <a href="#">公众号管理</a>
                </li>
                <li class="active">新增公众号</li>
            </ul><!-- /.breadcrumb -->
        </div>

        <div class="page-content">
            <div class="page-header">
                <h1>
                    新增公众号
                    <small>
                        <i class="ace-icon fa fa-angle-double-right"></i>
                        New Account
                    </small>
                </h1>
            </div><!-- /.page-header -->

            <div class="row">
                <div class="col-xs-12">
                    <!-- PAGE CONTENT BEGINS -->



                    <div class="col-sm-offset-2 col-sm-8">
                        <div class="widget-box">
                            <div class="widget-header widget-header-blue widget-header-flat">
                                <h4 class="widget-title lighter">新增公众号</h4>
                            </div>

                            <div class="widget-body">
                                <div class="widget-main">
                                    <div id="fuelux-wizard" data-target="#step-container">
                                        <ul class="wizard-steps">
                                            <li data-target="#step1" class="active">
                                                <span class="step">1</span>
                                                <span class="title">增加基本信息</span>
                                            </li>

                                            <li data-target="#step2" class="active">
                                                <span class="step">2</span>
                                                <span class="title">配置公众平台</span>
                                            </li>

                                            <li data-target="#step3" class="active">
                                                <span class="step">3</span>
                                                <span class="title">保存接口配置</span>
                                            </li>


                                        </ul>
                                    </div>

                                    <hr>

                                    <div class="step-content pos-rel" id="step-container">
                                        <div class="step-pane active" id="step1">

                                            <form class="form-horizontal" id="sample-form" style="display: block;">
                                                <div class="form-group ">
                                                    <label for="ipt-appid" class="col-xs-12 col-sm-3 col-md-2 control-label no-padding-right">AppID</label>
                                                    <div class="col-xs-12 col-sm-5 col-md-7">
															<span class="block input-icon input-icon-right">
																<input type="text" id="ipt-appid" class="width-100">
																<i class="ace-icon fa fa-leaf"></i>
															</span>
                                                    </div>
                                                    <div class="help-block col-xs-12 col-sm-reset inline"> 必填项 </div>
                                                </div>
                                                <div class="form-group ">
                                                    <label for="ipt-appsecret" class="col-xs-12 col-sm-3 col-md-2 control-label no-padding-right">AppSecret</label>
                                                    <div class="col-xs-12 col-sm-5  col-md-7">
															<span class="block input-icon input-icon-right">
																<input type="text" id="ipt-appsecret" class="width-100" placeholder="保存后不可在修改，请正确填写">
																<i class="ace-icon fa fa-leaf"></i>
															</span>
                                                    </div>
                                                    <div class="help-block col-xs-12 col-sm-reset inline"> 必填项 </div>
                                                </div>
                                                <div class="form-group ">
                                                    <label for="ipt-key" class="col-xs-12 col-sm-3 col-md-2 control-label no-padding-right">EncodingAESKey </label>
                                                    <div class="col-xs-12 col-sm-5  col-md-7">
															<span class="block input-icon input-icon-right">
																<input type="text" id="ipt-key" class="width-100" placeholder="保存后不可在修改，请正确填写">
																<i class="ace-icon fa fa-leaf"></i>
															</span>
                                                    </div>
                                                    <div class="help-block col-xs-12 col-sm-reset inline"> 安全模式下必填项 </div>
                                                </div>
                                                <div class="form-group ">
                                                    <label for="ipt-key" class="col-xs-12 col-sm-3 col-md-2 control-label no-padding-right">授权验证文件 </label>
                                                    <div class="col-xs-12 col-sm-5  col-md-6">
                                                        <div id="uploader" class="wu-example">
                                                            <!--用来存放文件信息-->
                                                            <div id="thelist" class="uploader-list"></div>
                                                            <div class="btns">
                                                                <div id="picker">选择文件</div>
                                                                <button id="ctlBtn" class="btn btn-default">开始上传</button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="help-block col-xs-12 col-sm-reset inline"> <span class="upload-hint green"></span> </div>
                                                </div>
                                            </form>


                                        </div>



                                    </div>

                                    <hr>
                                    <div class="wizard-actions">
                                        <button class="btn btn-prev" disabled="disabled">
                                            <i class="ace-icon fa fa-arrow-left"></i>
                                            上一步
                                        </button>

                                        <button class="btn btn-success btn-next" data-last="Finish" id="btn-complete">

                                            保存完成
                                            <i class="ace-icon fa fa-arrow-right icon-on-right"></i></button>
                                    </div>
                                </div><!-- /.widget-main -->
                            </div><!-- /.widget-body -->
                        </div>
                    </div>





                    <!-- PAGE CONTENT ENDS -->
                </div><!-- /.col -->
                <div class="space-6"></div>

            </div><!-- /.row -->
        </div><!-- /.page-content -->
    </div><!-- /.main-content -->

    {include file="common/footer"}

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>
</div><!-- /.main-container -->

<!-- basic scripts -->
{include file="common/base_js"}
<script src="__PUBLIC__/static/js/webuploader-0.1.5/webuploader.js"></script>

<!-- inline scripts related to this page -->
<script type="text/javascript">

    !function($){
        "use strict";
        var uploader = null;
        var file_name = '';
        var file_id = 0;
       function init_uploader(){
           var BASE_URL = '__PUBLIC__/static/webuploader-0.1.5';
            uploader = WebUploader.create({
                duplicate :true,
                fileVal:'verify_file',
                // swf文件路径
               swf: BASE_URL + '/js/Uploader.swf',
                // 文件接收服务端。
               server: '{:url("uploadverify")}',

               // 选择文件的按钮。可选。
               // 内部根据当前运行是创建，可能是input元素，也可能是flash.
               pick: '#picker',

               // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
               resize: false
           });
            uploader.on("fileQueued",function(file){
               file_name =file.name;

               $('.upload-hint').text(file_name);
            });
            uploader.on("uploadSuccess",function(file,rsp){
                if(!rsp.error){
                    $('.upload-hint').text(rsp.errmsg);
                    file_id=rsp.data.id;
                }else{
                    layer.msg(rsp.errmsg);
                }
            });
            $('#ctlBtn').off("click").on("click",function(e){
               e.preventDefault();
               uploader.upload();
            });

       }


       function bind_events(){
           $('#btn-complete').off("click").on("click",function(e){
               e.preventDefault();
               prepare_data();
           })
       }
       function prepare_data(){
            var $appid= $.trim($('#ipt-appid').val());
            var $appsec= $.trim($('#ipt-appsecret').val());
           var $key= $.trim($('#ipt-key').val());
           if(!$appid){
               layer.msg("AppID 为必填项目，请重新填写");
               $('#ipt-appid').focus();return;
           }
           if(!$appsec){
               layer.msg("AppID 为必填项目，请重新填写");
               $('#ipt-appsecret').focus();return;
           }
           var data = {
               appid:$appid,
               secret:$appsec,
               encodingaeskey:$key,
               check_file:file_id
           };
           ajax_send(data);

       }
       function ajax_send(_data){
           $.ajax({
               url:'{:url("step_03")}',
               type:'post',
               data:_data,
               dataType:'json',
               success:function(rsp){
                   if(!rsp.error){
                       layer.msg(rsp.errmsg);
                       setTimeout(function(){
                           window.location.href="{:url('lists')}";
                       },1000);
                   }
               }
           });

       }
        $(function($) {
            init_uploader();
            bind_events();
        })

    }(jQuery);



</script>
</body>
</html>
